﻿using HZU.ZP.Data.Interfaces.Resume;
using HZU.ZP.Data.Models;
using HZU.ZP.Data.Models.Resume;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HZU.ZP.Data.Impl.Resume
{
    public class MasterSkillDao:IMasterSkillDao
    {
        private EFCoreDbContext _context;

        public MasterSkillDao(EFCoreDbContext context)
        {
            _context = context;
        }

        public void AddMasterSkill(MasterSkill masterSkill)
        {
            _context.MasterSkills.Add(masterSkill);
            _context.SaveChanges();
        }

        public void DeleteMasterSkill(int id)
        {
            var masterSkill = _context.MasterSkills.FirstOrDefault(e => e.Id == id);
            _context.MasterSkills.Remove(masterSkill);
            _context.SaveChanges();
        }

        public IList<MasterSkill> GetMasterSkillList(int ApplicanId)
        {
            return _context.MasterSkills.Where(e => e.ApplicantId == ApplicanId).ToList();
        }

        public void UpdateMasterSkill(MasterSkill masterSkill)
        {
            _context.MasterSkills.Update(masterSkill);
            _context.SaveChanges();
        }
    }
}
